package cn.yunhe.controller;

import cn.yunhe.model.Page;
import cn.yunhe.model.User;
import cn.yunhe.service.IUserService;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by zs on 2017/12/11.
 */
public class UserAction extends ActionSupport implements ModelDriven<Object> {

    @Resource
    private IUserService userService;

    private User user;

    private int pageSize;

    private int pageNum;

    private Page page;

    public String queryLikeUsers() {
        Map<String, Object> cond = new HashMap<String, Object>();
        cond.put("pageSize", pageSize);
        cond.put("pageNum", pageNum);
        cond.put("user", user);
        page = userService.queryLikeUsers(cond);
        return SUCCESS;

    }


    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public Page getPage() {
        return page;
    }

    public void setPage(Page page) {
        this.page = page;
    }

    public IUserService getUserService() {
        return userService;
    }

    public void setUserService(IUserService userService) {
        this.userService = userService;
    }

    @Override
    public Object getModel() {
        if (user == null) {
            user = new User();
        }
        return user;
    }
}
